<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>mini-vue</title>
</head>

<body>
    <input id="input-box" type="text">
    <div id="show-text"></div>
    <script>
        const showText = document.querySelector('#show-text')
        const inputBox = document.querySelector('#input-box')
        class VM {
            data = {
                value: ''
            }
            constructor() {
                Object.defineProperty(this.data, 'value', {
                    set(v) {
                        showText.textContent = v
                    },
                    get() {
                        return showText.textContent
                    }
                })
            }
        }

        const vm = new VM()
        inputBox.addEventListener('input', function (e) {
            vm.data.value = e.target.value
            console.log(vm.data.value)
        })
    </script>
</body>

</html>